package com.key.util;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;

import com.key.wanderbupt.R;

public class InfoText {
	
	public static Map<String,BuildingInfo> BuildingInfo = new LinkedHashMap<String,BuildingInfo>();
	
	public static class BuildingInfo {
		public int BuildingImage;
		public String BuildingInfos;
		
		public BuildingInfo( int BuildingImage,String BuildingInfo ) {
			this.BuildingImage = BuildingImage;
			this.BuildingInfos = BuildingInfo;
		}
	}
	
	public static void initBuildingInfo() {
		
		addBuildingInfo("The Second Building",R.drawable.secondbuilding,SecondBuilding);//0
		addBuildingInfo("The Comprehensive Office",R.drawable.comprehensiveoffice,ComprehensiveOffice);//1
		addBuildingInfo("The First Building",R.drawable.firstbuilding,FirstBuilding);//2
		addBuildingInfo("The Student Center",R.drawable.studentcenter,StudentCenter);//3
		addBuildingInfo("The Administrative Building",R.drawable.adminbuilding,AdminBuilding);//4
		addBuildingInfo("The First Canteen",R.drawable.firstcanteen,FirstCanteen);//5
		addBuildingInfo("The Second Canteen",R.drawable.secondcanteen,SecondCanteen);//6
		addBuildingInfo("The Fifth Dormitory",R.drawable.fifthdormitory,FifthDormitory);//7
		addBuildingInfo("The Six Dormitory",R.drawable.sixdormitory,SixDormitory);//8
		addBuildingInfo("The Second Dormitory",R.drawable.seconddormitory,SecondDormitory);//9
		addBuildingInfo("The First Dormitory",R.drawable.firstdormitory,FirstDormitory);//10
		addBuildingInfo("The Forth Dormitory",R.drawable.forthdormitory,ForthDormitory);//11
		addBuildingInfo("The Third Dormitory",R.drawable.thirddormitory,ThirdDormitory);//12
	}
	
	public static Set<String> searchBuilding( String text ) {
		
		if( BuildingInfo.size() == 0 ) {
			initBuildingInfo();
		}
		
		Set<String> result = new TreeSet<String>();
		Set<Entry<String,BuildingInfo>> set = BuildingInfo.entrySet();
		Iterator<Entry<String,BuildingInfo>> iter = set.iterator();
		while( iter.hasNext() ) {
			Entry<String,BuildingInfo> entry = iter.next();
			if( entry.getValue().BuildingInfos.indexOf(text) != -1 ) {
				result.add(entry.getKey());
			}
		}
		return result;
	}
	
	private static void addBuildingInfo( String name,int image,String info ) {
		
		BuildingInfo bf = new BuildingInfo(image,info);
		BuildingInfo.put(name,bf);
	}

	public static String SecondBuilding = "The second teaching building is the largest teaching building in the campus." +
			"It includes a five floor regular building which provides restrooms for teachers," +
			"classrooms for students and sketch rooms for art students," +
			"and a two -floor sector building which is mainly used by students of international school," +
			"but it is sometimes used to hold parties, competitions and meetings.";
	
	public static String ComprehensiveOffice = "The comprehensive office building is mainly used to provide office for officials in the school," +
			"like security office and the library and the school infirmary are also situated in here.";
	
	public static String FirstBuilding = "The first teaching building is primarily used by students of international school," +
			"software school and minority school. It includes few offices," +
			"a couple of libraries for postgraduate students and four computer rooms for students.";
	
	public static String StudentCenter = "The student center is a building with multiple functions." +
			"There are post office on the first floor and a cute book store in the corner." +
			"The activity hall on the second floor is pretty spacious and it is a place where many clubs get together.";

	public static String AdminBuilding = "Administrative building is place where teachers of international school work.";
	
	public static String FirstCanteen = "The first canteen provides students with foods of reasonable prices." +
			"It is the principle place for teachers and students to eat." +
			"Students can only pay by school cards.";
	
	public static String SecondCanteen = "The second canteen is a three-floor building which has a fancy environment." +
			"Besides regular foods," +
			"teachers and students can also order food in the third floor which is a perfect place to get together.";
	
	public static String FifthDormitory = "The fifth dormitory building is a place where fresh students live except " +
			"students form international school and minority school." +
			"The environment is good as there is elevator in the building and balcony in every dormitory.";
	
	public static String SixDormitory = "The sixth dormitory building is used for postgraduates to live.";

	public static String SecondDormitory = "The second dormitory building is a place where the minority students live.";
	
	public static String FirstDormitory =  "The first dormitory building is used as the dormitory for students of international school.";
	
	public static String ForthDormitory = "The forth dormitory building is used by students of international school.";
	
	public static String ThirdDormitory =  "The third dormitory building is used by students of international school.";
}
